package com.lead.security.utils;

import java.util.Locale;

/**
 *
 * @author zyq
 */
public class HexUtil {

    /**
     * 将byte数组转换为16进制字符串
     * @param b
     * @return 返回转换后的字符串.
     */
    public static String toHex(byte[] b) {
        if (b == null) {
            return "";
        }
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < b.length; i++) {
            String hex = Integer.toHexString(b[i] & 0xFF);
            if (hex.length() == 1) {
                hex = '0' + hex;
            }
            sb.append(hex);
        }
        return sb.toString().toLowerCase(Locale.CHINESE);
    }



}
